<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>退货管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出退货数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/ka/salesReturn/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/ka/salesReturn/list");
			$("#searchForm").submit();
        	return false;
        }
		
		function clearForm(){
			$("#categoryId").val('');
			$("#productCode").val('');
			$("#supplierId").val('');
			$("#state").val('');
			$("#searchForm").attr("action","${ctx}/ka/salesReturn/list");
			$("#searchForm").submit();
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ka/salesReturn/">退货管理列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="salesReturn" action="${ctx}/ka/salesReturn/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<ul class="ul-form">
			<li><label>品类：</label>
				<form:select path="categoryId" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getCategory() }" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>供应商：</label>
				<form:select path="supplierId" class="input-medium" >
					<form:option value="" label="全部"/>
					<form:options items="${fns:getSupplier()}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>渠道：</label>
				<form:select path="canalId" class="input-medium" >
					<form:option value="" label="全部"/>
					<form:options items="${fns:getCanal()}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>货号：</label>
				<form:input path="productCode" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>退货类别：</label>
				<form:select path="state" class="input-medium">
					<form:option value="" label="全部"></form:option>
					<form:option value="1" label="残次品"></form:option>
					<form:option value="0" label="非残次品"></form:option>
					<form:option value="2" label="供应商退货"></form:option>
				</form:select>
			</li>
			<li><label>退货时间：</label>
				<input name="startDate" id="startDate" type="text"  maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${salesReturn.startDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>至<input name="endDate" id="endDate" type="text"  maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${salesReturn.endDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" onclick="clearForm()" value="重置"/></li>
			<li class="btns"><input id="btnExport" class="btn btn-primary" type="button" value="导出"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>品类</th>
				<th>货号</th>
				<th>供应商</th>
				<th>尺码</th>
				<th>颜色</th>
				<th>退货件数</th>
				<th>入库价格</th>
				<th>出库价格</th>
				<th>销售价格</th>
				<th>活动优惠</th>
				<th>实际销售价格</th>
				<th>渠道</th>
				<th>退货时间</th>
				<th>快递公司</th>
				<th>运单号</th>
				<th>订单号</th>
				<th>退货类别</th>
				<shiro:hasPermission name="ka:salesReturn:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="salesReturn">
			<tr>
				<td>
					${salesReturn.categoryName}
				</td>
				<td>
					${salesReturn.productCode}
				</td>
				<td>
					${salesReturn.supplierName}
				</td>
				<td>
					${salesReturn.sizeName}
				</td>
				<td>
					${salesReturn.colorName}
				</td>
				<td>
					${salesReturn.amount}
				</td>
				<td>
					${salesReturn.instockPrice}
				</td>
				<td>
					${salesReturn.outstockPrice}
				</td>
				<td>
					${salesReturn.salesPrice}
				</td>
				<td>
					${salesReturn.activePrice}
				</td>
				<td>
					${salesReturn.realPrice}
				</td>
				<td>
					${salesReturn.canalName}
				</td>
				<td>
					<fmt:formatDate value="${salesReturn.outstockDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${salesReturn.carrierName}
				</td>
				<td>
					${salesReturn.waybillNumber}
				</td>
				<td>
					${salesReturn.orderNumber}
				</td>
				<td>
					<c:choose>
						<c:when test="${salesReturn.state==0}">退货(非残次品)</c:when>
						<c:when test="${salesReturn.state==1}">退货(残次品)</c:when>
						<c:when test="${salesReturn.state==2}">退货(供应商退货)</c:when>
					</c:choose>
				</td>
				<shiro:hasPermission name="ka:salesReturn:edit"><td>
					<a href="${ctx}/ka/salesReturn/logisticsForm?id=${salesReturn.id}">物流信息</a>
					<a href="${ctx}/ka/salesReturn/delete?id=${salesReturn.id}" onclick="return confirmx('确认要删除该退货信息吗？', this.href)">删除</a>
					<a href="${ctx}/ka/salesReturn/form?id=${salesReturn.id}">修改</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<table align="right" border="0">
		<tr>
			<td>合计：</td>
			<td>总件数:${statistics.total }(件)&nbsp;&nbsp;</td>
			<td>总入库价格：${statistics.instockPriceTotal }(元)&nbsp;&nbsp;</td>
			<td>总出库价格：${statistics.outstockPriceTotal }(元)&nbsp;&nbsp;</td>
			<td>实际销售价格：${statistics.realPriceTotal }(元)</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td>平均入库价格:${statistics.instockPriceAvg }(元)</td>
			<td>平均出库价格:${statistics.outstockPriceAvg }(元)</td>
			<td>平均实际销售价格:${statistics.realPriceAvg }(元)</td>
		</tr>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>